/**
 * 编辑产品信息交易
 * @author liuguangshuai@gmail.com
 * @系统名称：定制化辅助生成制造系统
 * 
 */

package org.ccams.tran;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.ccams.domain.TGoods;
import org.ccams.util.StrHelper;
import org.ccams.util.Utils;

public class Tran13123 extends AbstractJsonTran {

	@SuppressWarnings("unchecked")
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String goodsid = (String) request.getParameter("goodsid");
		String goodsNo = (String) request.getParameter("goodsno");
		String goodName = (String) request.getParameter("goodsname");
		String typename = (String) request.getParameter("typename");
		String classname = (String) request.getParameter("classname");
		String kindname = (String) request.getParameter("kindname");
		String spec = (String) request.getParameter("spec");
		String spellCode = (String) request.getParameter("spellcode");
		String unit = (String) request.getParameter("unit");
		String fzxs1 = (String) request.getParameter("fzxs1");
		String fzxs2 = (String) request.getParameter("fzxs2");
		String fzunit1 = (String) request.getParameter("fzunit1");
		String fzunit2 = (String) request.getParameter("fzunit2");
		String servicetext = (String) request.getParameter("servicetext");
		String reftext = (String) request.getParameter("reftext");
		String indication = (String) request.getParameter("indication");
		String filename = (String) request.getParameter("filename");
		TGoods t = new TGoods();
		t.setGoodsid(Long.parseLong(goodsid));
		t.setFzunit1(fzunit1);
		t.setFzunit2(fzunit2);
		t.setCreateddate(Utils.getCurrentDateTime());
		t.setFzxs1(StrHelper.getInt(fzxs1, 1));
		t.setFzxs2(StrHelper.getInt(fzxs2, 1));
		t.setGoodsclassno(classname);
		t.setGoodskindno(kindname);
		t.setGoodsname(goodName);
		t.setGoodsno(goodsNo);
		t.setGoodstypeno(typename);
		t.setIndication(indication);
		t.setReftext(reftext);
		t.setServicetext(servicetext);
		t.setSpec(spec);
		t.setSpellcode(spellCode);
		t.setUnit(unit);	
		t.setFilename(filename);
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		boolean success = false;
		String message = "";
		int i = getCcamsService().getTgoodsDao().updateTGoods(t);
		if (i == 1) {
			success = true;
			message = "产品修改成功";
		} else {
			success = false;
			message = "产品修改失败";
		}
		jsonMap.put("success", success);
		jsonMap.put("message", message);
		json.putAll(jsonMap);
	}
}
